package com.example.myapplication.tack_17.adappter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication.R;
import com.example.myapplication.tack_17.LuXianActivity;
import com.example.myapplication.tack_17.data.RotueData02;
import com.example.myapplication.tack_17.data.RouteData;
import com.example.myapplication.utils.Common;

import java.util.List;


public class Route02Adapter extends RecyclerView.Adapter<Route02Adapter.My> {
    private List<RotueData02.RowsDTO> list;
    private Context context;
    private View view;

    public Route02Adapter(List<RotueData02.RowsDTO> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public My onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        view = LayoutInflater.from(context).inflate(R.layout.tack_17_route02,null);
        return new My(view);
    }

    @Override
    public void onBindViewHolder(@NonNull My holder, int position) {
        if(position == 0){
            holder.name.setText("起点:"+list.get(position).getName());
        }
        if(position == (list.size()-1)){
            holder.name.setText("终点站:"+list.get(position).getName());
        }else if(position != 0 && position != list.size()-1){
            holder.name.setText(list.get(position).getName());
        }


    }



    @Override
    public int getItemCount() {
        return list != null?list.size():0;
    }

    public class My extends RecyclerView.ViewHolder{
        private TextView name;
        private LinearLayout line;
        public My(@NonNull View itemView) {
            super(itemView);
            name = view.findViewById(R.id.name);
            line = view.findViewById(R.id.line);
        }
    }
}
